﻿#ifndef    _SELECTPOLL_H
#define _SELECTPOLL_H

#include <map>
#include "abstractpoll.h"
#include "fdset.h"

using namespace std;

namespace SocketLib
{
class SocketFD;

class SelectPoll : public SocketFDPoll
{
public:
    SelectPoll();
    void                doPoll(long aTimeout = 1);

    void                addSocketFD(SocketFD* pSocketFD);
    void                delSocketFD(SocketFD* pSocketFD);

private:
    typedef map<sock, SocketFD*> ACTIVELIST;

    void                onPollError();
    bool                onSockedFDRecv(SocketFD* pSocketFD);

    SocketSet           m_socketSet;
    const fd_set*       m_readSet;

    ACTIVELIST          m_socketFdList;
};
}

#endif
